package com.zhihaoliang.busEncy.adapter

import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.alibaba.android.vlayout.DelegateAdapter
import com.alibaba.android.vlayout.LayoutHelper
import com.alibaba.android.vlayout.layout.LinearLayoutHelper
import com.hbmcc.heshenghuo.model.http.bean.TitleAndUrlBean
import com.hbmcc.heshenghuo.view.FloorTitle
import com.zhihaoliang.busEncy.R


class BusTitleAdapter internal constructor(var data: TitleAndUrlBean) :
    DelegateAdapter.Adapter<BusTitleAdapter.ViewHolder>() {
    override fun onCreateLayoutHelper(): LayoutHelper {
        return LinearLayoutHelper()
    }


    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
        return ViewHolder(
            LayoutInflater.from(parent.context).inflate(R.layout.floor_title_all, parent, false)
        )
    }

    override fun onBindViewHolder(holder: ViewHolder, position: Int) {
        initFloorTitle(holder.floorTitle, data)

    }

    private fun initFloorTitle(floorTitle: FloorTitle, titleAndUrlBean: TitleAndUrlBean?) {
        floorTitle.setBean(titleAndUrlBean)
        floorTitle.height = 50
        floorTitle.setTitleSize(20f)
    }

    override fun getItemCount(): Int {
        return 1

    }

    override fun getItemViewType(position: Int): Int {
        return R.layout.floor_title_all
    }

    class ViewHolder(var view: View) : RecyclerView.ViewHolder(view) {
        var floorTitle = view.findViewById<FloorTitle>(R.id.floorTitle)
    }

}